<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?php
include  'admin/Util.php';
include  'slider/SliderGallery.php';
?>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">
    <head>
        <?php
        include  'meta.php';
        ?>
        <title><?php echo Constants::$mainHeader ?></title>
        <?php
        include  'headIcon.php';
        include  'headJSCSS.php';
        $link = Util::getLink();

        $query = sprintf(Util::$select_jornakDestination,
            mysql_real_escape_string("2")
        );

        $result = mysql_query($query);

        if (!$result) {
            die('Could not query:' . mysql_error());
        }

        $num_rows = mysql_num_rows($result);

        $contents = file_get_contents('slider/sliderCSS.php');
        for ($k = 0; $k < $num_rows; $k++) {
            echo  str_replace('$getID', $k+1, $contents);
        }
        ?>
    </head>
    <body>
        <?php
        $contents = file_get_contents('slider/sliderScript.php');
        for ($k = 0; $k < $num_rows; $k++) {
            echo  str_replace('$getID', $k+1, $contents);
        }
        ?>

        <h1><?php echo Constants::$mainHeader ?></h1>

        <?php
        include  'menu.php';
        ?>

        <!-- CONTENTS START -->

        <div id="contents">
            <div class="boxtop"></div>
            <div class="boxhdr"><h2>Projects</h2></div>
            <div class="boxtxt">

                <?php

                $i = 0;
                while ($row = mysql_fetch_assoc($result)) {
                    $i++;
                    $textID[$i] = $row['textid'];
                    $time[$i] = $row['time'];
                }
                $count = count($textID);

                for ($i = 1; $i < $count+1; $i++) {
                    if ($textID[$i] == null) break;
                    $query = sprintf(Util::$select_jornakText,
                        mysql_real_escape_string($textID[$i])
                    );

                    $result = mysql_query($query);

                    if (!$result) {
                        die('Could not query:' . mysql_error());
                    }

                    while ($row = mysql_fetch_assoc($result)) {
                        echo '<h3><a href="project-detail.php?id='.$textID[$i].'">'.stripslashes($row['header'])."</a></h3>";
                        echo '<p>'.stripslashes($row['list'])."</p>";
                        $myArray = explode(';',$row['imgs']);
                        if ($myArray[0] != null) {
                            SliderGallery::getSliderEven($myArray, $i);
                        }
                        if ($i < $count) {
                            echo "<hr />" ;
                        }else {
                            echo "<br /> " ;
                        }
                    }
                }

                Util::closeLink($link);

                ?>
                <div id="cleaner"></div>
            </div>
            <div class="boxbtm"></div>
        </div>

        <!-- CONTENTS END -->

        <?php
        include  'footer.php';
        ?>

    </body>
    <?php include 'googleAnalyt.php';?>
</html>